package com.SpringMVC;

import java.util.HashMap;
import java.util.Map;

import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.SpringMVC.Person;

@Controller
public class TestController {
    /**
     * 接收页面请求的JSON参数，并返回JSON格式的结果
     */
    @RequestMapping("/testJson")
    @ResponseBody
    public Person testJson(@RequestBody Person user) {
        // 打印接收的JSON格式数据
        System.out.println("pname=" + user.getName() + ",password="
                + user.getPassword() + ",page" + user.getPage());
        ;
        // 返回JSON格式的响应
        return user;
    }
    @RequestMapping("/testJson1")
    @ResponseBody
    public Person testJson1() {
        Person user = new Person();
        user.setName("asdf");
        user.setPage(12);
        user.setPassword("asdfasdf");
        
        // 打印接收的JSON格式数据
        System.out.println("pname=" + user.getName() + ",password="
                + user.getPassword() + ",page" + user.getPage());
        ;
        return user;
    }
}
